   {template 'header'}

{if $setting['istopitems']==2}
<script type="text/javascript" src="{$res}js/swiper-3.3.1.jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="{$res}js/swiper-3.3.1.min.css">
{/if}

<!--script src="{$res}js/jquery.masonry.min.js"></script-->
<!--script src="{$res}js/jquery.masonry.pkgd.min.js"></script-->
<script src="../addons/bsht_tbk/res/js/main.js"></script>
<!--script src="../addons/bsht_tbk/res/js/jquery.cookie.js"></script-->
<script src="../addons/bsht_tbk/res/js/nb_plus.js"></script>
<link rel="stylesheet" type="text/css" href="../addons/bsht_tbk/res/css/nb_plus.css" />
  
{if $thiscate['istopstatus']==1}
<!-- 通告 -->
<center>
<div class="swiper-container" style="padding:5px;background-color:#fff">
    <div class="swiper-wrapper">
        <div class="swiper-slide">
		{if $thiscate['toppic']}
		<a href="{if !empty($thiscate['topurl'])}{$thiscate['topurl']}{else}javascript:{/if}"><img src="{if !empty($thiscate['toppic'])}{php echo tomedia($thiscate['toppic']);}{else}{$res}images/noads.jpg{/if}">
		</a>
		{else}
        <div style="max-width:99%;text-align:left;">{$thiscate['toptxt']}</div>
		{/if}
		</div>
    </div>
</div>
</center>
<!-- 通告 -->
{/if}	

{if $setting['istopitems']==2 && $tops}
<!--nb_plus-->
<div id="containter" class="container">
<div id="containter index_goods">
    <div class="contain-product relative">
            <div class="index_list_title">
        <span class="intro_title"><i>今日福利</i> <em>新人抢福利 | 每日10:00 记得来抢！</em></span>
        <!--span class="index_list_eachall"><a href="">全部</a></span-->
    </div>
<div class="contain--product-list swiper2">
    <ul class="swiper-wrapper">
            {loop $tops $i}
			<li class="relative swiper-slide">
                <div class="contain-prolist-in">
                    <a href="{$i['topurl']}" class="ImgOut">
                        <div class="allpreContainer">
                            <div class="inoutbg" style="background-image: url(res/images/smallbg.png); background-size: cover; background-position: 50% 50%; background-repeat: no-repeat;">
                            </div>
                            <img class="preloadbg lazy-bk" src="../addons/bsht_tbk/res/images/load.gif"  data-bk="{$i['itempic']}{$setting['maxpic']}.jpg" loaded="false">
                            <div class="DSbg" style="background-image: url(); background-size: cover; background-position: 50% 50%; background-repeat: no-repeat;">
                            </div>
                        </div>
                    </a>
                    <div class="contain-prolist-text">
                        <h1><a href="{$i['topurl']}">{$i['title']}</a></h1>
                        <h2>
                            <span>&yen;{$i['itemfee2']}</span>
                            <font>&yen;{$i['itemfee']}</font>
                        </h2>
                    </div>
                    <a href="javascript:;" class="new-couponnb" data-bk="{$i['itempic']}{$setting['maxpic']}.jpg" data-id="{$i['id']}"><span>领劵</span><span>立减{$i['jiage2']}元</span></a>
                </div>
            </li>
			{/loop}
    </ul>
</div>
</div>
<!--nb_plus-->
{/if}


	<div id="msv">
     <link rel="stylesheet" type="text/css" href="{$res}static/jwap/css/newpulic.css" />
    </div>





    <div id="goods">
     <section class="goods" id="pageCon">
      <ul class="goods-list list_box clear" id="list_box">
      </ul>
     </section>
	 {if $setting['autoclick']!=2}
	 {php $tpage=$_GPC['page'];}
     {if empty($_GPC['page'])}{php $tpage=1;$npage=$tpage-1;$npage2=$tpage+1;}{else}{php $npage=$tpage-1;$npage2=$tpage+1;}{/if}
	 
	 <div id="list_more" class="loading" style="margin-top:10px">
	 <span onclick="get_list(0);">查看更多</span>
	 </div>
	 {else}
	 {php $tpage=$_GPC['page'];}
     {if empty($_GPC['page'])}{php $tpage=1;$npage=$tpage-1;$npage2=$tpage+1;}{else}{php $npage=$tpage-1;$npage2=$tpage+1;}{/if}
	 <div id="list_more2" class="loading" style="margin-top:10px">

     {if $tpage!=1}
	 <span style="float:left;width:40%"><a href="{php echo $this->createMobileUrl('list_all', array('page' => $npage,'cate_id' => $_GPC['cate_id']));}">< 上一页</a></span>
	 {/if}

	 {if $tpage!=1}
	 <span style="float:left;width:20%" id="shispage" onclick="$('#shispage').hide();$('#newpage').show();"><a href="javascript:">{$_GPC['page']}</a></span>
	 <span style="float:left;width:20%;display:none" id="newpage"><input style="width:50%;text-align: center;" type="number" id="jumpPage" value="" placeholder="{$_GPC['page']}">&nbsp;<a href="javascript:" onclick="jumppage();">前往</a></span>
	 <script>
	 function jumppage(){
	 var jumppagenum = $('#jumpPage').val();
	 if(jumppagenum){
	 if(jumppagenum<=0){jumppagenum=1;}
	 var jumpurl = "{php echo $this->createMobileUrl('list_all');}&page="+jumppagenum;
	 window.location.href=jumpurl;
	 }else{
	 
	 }
	 }
	 </script>
	 {/if}

	 <span style="float:right;{if $tpage!=1}width:40%{else}width:100%{/if}"><a href="{php echo $this->createMobileUrl('list_all', array('page' => $npage2,'cate_id' => $_GPC['cate_id']));}">下一页 ></a></span>
	 </div>
	 {/if}
    </div>
 
		

<script type="text/javascript">
$(document).ready(function(){ 


{if $setting['skin1tip']!=1}
//nb_plus
$(document).delegate(".new-coupon,.goodsget", "click", function () {
        var $this = $(this);
        var yhjid = $this.data("id");
		var nbpic = $this.data("bk");
        $.ajax({
            type: "post",
            url: "{php echo $this->createMobileUrl('yhj_tkl_nb_ajax', array('op' => 'nbpost'));}",
            dataType: "json",
            data: { id: yhjid },
            success: function (data) {
                if (data.code == 1000) {
                    popTao(nbpic, "淘口令", "对不起，优惠券已领空或产品已下架！");
                    //$(".taokaobox").html("<div class='popwcc'><a href='javascript:;' onclick='' class='popwcomfirm'>返回</a></div>");
                }
               else {
                    popTao(nbpic, "淘口令", "复制框内整段文字，打开【手机淘宝】即可【领取优惠券】并购买"+data.tkl);
                    {if $setting['isdd']==1}
					$(".taotip").html("预计奖励：" + data.yuji).show();
				    {/if}
                }
                selection();
                var hiturl = "{php echo $this->createMobileUrl('hit_ajax',array('act'=>'itemall'));}&id="+yhjid;		
                $.post(hiturl, function(dat){});
            }
        });
});
//nb_plus
{/if}


var limit = {$tpage};
var tpyename = $('#tmptpye').val();
var minfee =  $('#minfee').val();
var maxfee =  $('#maxfee').val();
if(!typename){typename='moren';}

/*
if($.cookie('bsht_tbk_tpyename')){  
tpyename = $.cookie('bsht_tbk_tpyename');  
}

if($.cookie('bsht_tbk_limit')){  
limit = $.cookie('bsht_tbk_limit');  
}
*/

function get_list(ty){
    
/*$.cookie('bsht_tbk_limit', limit , { path: '/', expires: 1});
$.cookie('bsht_tbk_tpyename', tpyename , { path: '/', expires: 1});
$.cookie('bsht_tbk_minfee', minfee , { path: '/', expires: 1});
$.cookie('bsht_tbk_maxfee', maxfee , { path: '/', expires: 1});
*/


    if(ty==1){
	   $("#pageCon .list_box").html('');
	}else{
	   $("#list_more").html('<div class="am-text-secondary"><span class="am-icon-spinner am-icon-spin"></span> 卖命加载中...</div>');
	   
	}


	$.ajax({
	    type : "post",
	    url : "{php echo $this->createMobileUrl('list_all_ajax',array('op'=>'list','cate_id'=>$cate_id))}",
	    data : {
	    	limit:limit,
			typename:typename,
			minfee:minfee,
			maxfee:maxfee,
	    },
        dataType : "json",		
	    success : function(data) {
	    	if(data.status==200){

					var list = data.content;
						var content = '';
						for(var i=0; i<list.length; i++){

                            

{if $setting['skin']==1 || empty($setting['skin'])}

var maxw = $('.app').width();
  
content += '<li class="picCon"><div style="float:left; width:16px; height:16px; background:url('+list[i]['icon']+'); margin-left:5px; margin-top:5px;position:absolute;z-index:10"></div><a class="goods-a new-coupon" name="'+list[i]['yhjurl2']+'&maxw='+maxw+'" class="abuy yhjurl2 new-coupon" id="'+list[i]['id']+'" data-id="'+list[i]['id']+'" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" onclick="yhjjumpurl(this);">'
+'<img class="loazd lazy-bk" src="../addons/bsht_tbk/res/images/load.gif" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" /></a>'
+'<a name="'+list[i]['yhjurl2']+'&maxw='+maxw+'" class="abuy yhjurl2 new-coupon" id="'+list[i]['id']+'" data-id="'+list[i]['id']+'" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" onclick="yhjjumpurl(this);"><h3 class="tith3">'+list[i]['title']+'</h3>'
+'<div class="list-price buy"><span class="price-new"><i class="i-baoyou">包邮</i>'
+'<i class="i-quan">内部券'+list[i]['jiage2']+'元</i></span><span style="float:right;padding-right:10px;padding-top:2px;color:rgba(171, 171, 171, 1);font-size:12px">销量'+list[i]['itemmsell']+'</span></div><div class="list-price buy">'
+'<span class="price-new fs12"><span style="text-decoration: line-through;color: rgba(171, 171, 171, 1);">￥'+list[i]['itemfee']+'</span> 券后 '+list[i]['jiage']+'<i>元</i></span></div></a>'
+'<div class="b-btndiv"><div class="btn-l"><div class="btn-wai">'
+'<div class="btn-nei"><!--a href="'+list[i]['yhjurl']+'" class="abuy"--><a name="'+list[i]['yhjurl2']+'&maxw='+maxw+'" class="abuy yhjurl2 new-coupon" id="'+list[i]['id']+'" data-id="'+list[i]['id']+'" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" onclick="yhjjumpurl(this);">领券</a></div></div></div>'
+'<div class="btn-l"><div class="btn-wai">'
+'<div class="btn-nei2"><a href="'+list[i]['url']+'" class="ashare">详情</a></div></div></div></div></li>';
		  
{/if}
{if $setting['skin']==2}

         content += '<a name="'+list[i]['id']+'"></a><li class="picCon"><a class="goods-a" href="'+list[i]['url']+'#'+list[i]['id']+'">'
		 +'<img class="loazd lazy-bk" src="../addons/bsht_tbk/res/images/load.gif" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" /></a>'
		 +'<a href="'+list[i]['url']+'#'+list[i]['id']+'">'
		 +'<h3>'+list[i]['title']+'</h3>'
         +'<div class="list-price buy">'
         +'<span class="price-new"><i>券后 ￥</i>'+list[i]['jiage']+'</span>'
         +'<!--span class="qhj" style="margin-left:5px">'+list[i]['tag']+'</span-->'
         +'<a id="J_weixin" href="'+list[i]['url']+'#'+list[i]['id']+'" class="coupon"><span class="good-btn" style="color:#999">销量'+list[i]['itemmsell']+'</span></a>'
         +'</div></a>'
         +'<div class="lingquan">'
         +'<a id="J_weixin" href="'+list[i]['yhjurl']+'#'+list[i]['id']+'" class="coupon"><span>'+list[i]['jiage2']+'元券</span></a>'
         +'</div></li>';

{/if}

{if $setting['skin']==3}


content += '<div class="fq-background-white am-margin-top  am-margin-horizontal-xs" style="border-radius: 0 10px 10px 0;background:#fff;border:0px solid #fffeee;">'
+'<a name="'+list[i]['id']+'"></a>'
+'<div class="am-inline-block am-margin-vertical-xs am-margin-left-xs" style="width:33%">'
+'<a href="'+list[i]['url']+'#'+list[i]['id']+'" data-id="'+list[i]['itemid']+'" data-p="1" class="tobuy"><img src="../addons/bsht_tbk/res/images/load.gif" data-bk="'+list[i]['pic']+'{$setting['maxpic']}.jpg" class="fq-image lazy-bk" /></a>'
+'</div><div class="am-g am-fr" style="width:64%; height:100px;">'
+'<div class="am-u-sm-7 am-padding-left-0 am-padding-right-xs am-padding-top-xs">'
+'<strong data-id="'+list[i]['itemid']+'" class="line-clamp am-text-sm am-margin-bottom-xs" id="item_details">'
+'<i class="iconfont icon-tianmaoT" style="color:#bd0100; font-size:14px;"></i>'+list[i]['title']+'</strong>'
+'<div class="am-cf" style="line-height:2.3">'
+'<span class="am-text-xs fq-color-gray am-fl" style="text-decoration:line-through">￥'+list[i]['itemfee']+'</span>'
+'<span class="am-text-xs fq-color-gray am-fr">销量'+list[i]['itemmsell']+'</span>'
+'</div><div class="fq-color-danger am-fl">'
+'<span class="am-text-xs">券后包邮</span>' 
+'<strong class="am-text-lg price">'+list[i]['jiage']+'</strong>'
+'</div></div><div class="am-text-center am-u-sm-5 fq-prize am-padding-0" style="border-radius: 0 10px 10px 0">'
+'<div class="am-text-sm am-margin-left-xs" style=" background:linear-gradient(#f9304c,#f54d23);border-radius: 0 10px 10px 0; height:112px;">'
+'<div class=" am-fl am-text-sm fq-discount" style="margin-top:0px">'
+'<span class="am-text-sm fq-text-white" style="color:#fff">￥</span>'
+'<span class="am-text-xl fq-text-white" style="color:#fff">'+list[i]['jiage2']+'</span>'
+'<a href="'+list[i]['url']+'#'+list[i]['id']+'" class="tobuy am-text-sm fq-background-white am-radius am-block fq-a-focus am-margin-top-sm" style="padding:2px 4px;color:#f54d23;background:#fff">领券购买</a>'
+'</div><div class="am-round second-found am-inline-block am-fr"></div></div></div></div></div>';


{/if}





						}
                        $("#pageCon .list_box").append(content);
						var aa = $(".goods-list li").innerWidth();
                        $(".goods-list li img").css('height',aa);
						if(list.length=={if $setting['pageno']}{$setting['pageno']}{else}10{/if}){
							$("#list_more").html('<span class="am-text-secondary" onclick="get_list(0);">点击查看更多</span>');
						}else{
							$("#list_more").html('<span></span>');
							$("#list_more").fadeOut(500);
						}		
	                    limit++;

						

//waterfall();
lazy_img();
		    }else if(data.status==-103){
	    		$("#list_more").html('<span>没有更多记录！</span>');
				//dialog("没有更多记录！");
				//$("#list_more").fadeOut(500);
				//limit=1;
				//get_list(0);
				location.reload();

	    	}else{
			    $("#list_more").html('<span>没有更多记录！</span>');
				//dialog("没有更多记录！！");
				$("#list_more").fadeOut(500);
			}    	
	    },
	    error : function(xhr, type) {

	    }
	});
	    

}


get_list(0);


$(".xl_div_002").off("click").on("click",function(){
       $("#pageCon .list_box").html('');
	   typename =  $(this).attr("data-id");
	   $('#tmptpye').val(typename);
	   typetxt =  $(this).html();
	   $('#dc_xl_002').html(typetxt);
	   $('#xl_002').css("height","0px");
	   sq_xl();
	   limit = 1;
	   get_list(0);

	   //alert(typename);
});


$(".xl_div_006_3").off("click").on("click",function(){
       $("#pageCon .list_box").html('');
	   minfee =  $('#minfee').val();
	   maxfee =  $('#maxfee').val();
	   $('#xl_002').css("height","0px");
	   sq_xl();
	   limit = 1;
	   get_list(0);

	   //alert(typename);
});


//==============自动加载=============
{if $setting['autoclick']==1}
//获取滚动条当前的位置 
function getScrollTop() { 
var scrollTop = 0; 
if (document.documentElement && document.documentElement.scrollTop) { 
scrollTop = document.documentElement.scrollTop; 
} 
else if (document.body) { 
scrollTop = document.body.scrollTop; 
} 
return scrollTop; 
} 

//获取当前可是范围的高度 
function getClientHeight() { 
var clientHeight = 0; 
if (document.body.clientHeight && document.documentElement.clientHeight) { 
clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight); 
} 
else { 
clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight); 
} 
return clientHeight; 
} 

//获取文档完整的高度 
function getScrollHeight() {
var getScrollHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
return getScrollHeight; 
} 


$(window).scroll(function () { 
if (getScrollTop() + getClientHeight() == getScrollHeight()) { 
//alert("到达底部"); 
get_list(0);
} 
});

{/if}
//==============自动加载=============  

function waterfall(limit){
$container = $('#list_box');
$container.masonry('reload');
	$container.imagesLoaded(function() {
		lazy_img();	
		$container.masonry({
			itemSelector: '.picCon',
			isFitWidth: false,//是否根据浏览器窗口大小自动适应默认false
			//gutter: 20,
			isAnimated: false,//是否采用jquery动画进行重拍版
			isRTL:false,//设置布局的排列方式，即：定位砖块时，是从左向右排列还是从右向左排列。默认值为false，即从左向右
            isResizable: true,//是否自动布局默认true
			});
		});
}


});    


function yhjjumpurl(obj){
{if $setting['skin1tip']==1} 
 var url = obj.name;
 //alert(url);
 layer.open({
  type: 2,
  title: false,
  shadeClose: true,
  shade: 0.8,
  area: ['85%', '85%'],
  content: url
}); 
{/if}
}
</script>


<script>        
  var swiper = new Swiper('.swiper-container', {
            pagination: '.swiper-pagination',
            paginationClickable: true,
            loop: true,
			effect:'flip',
			autoplay:5000,
        });
  var swiper2 = new Swiper('.swiper2', {
            slidesPerView: 'auto',
            paginationClickable: true,
            freeMode: true,
			autoplay:3000,
			pagination: '.swiper-pagination',
            
  });
</script>

    {template 'foot'}
	{template 'footer'}